package com.bana.fvs.protocol;

import com.bana.fvs.model.ControllerText;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

public class QueryControllerVersion {
    public int getId()
    {
        return 0x17;
    }

    public byte[] toBuffer(int kzqbsm)
    {
        byte[] buffer=new byte[6];
        buffer[0]=(byte)0x81;
        buffer[1]=(byte)kzqbsm;
        buffer[2]=(byte)getId();
        buffer[3]=(byte)0x00;
        buffer[4]=(byte)0x00;
        buffer[5]=(byte)0xff;
        return buffer;
    }

    public String toModel(byte[] buffer) throws IOException {

        if(buffer.length<23)
        {
            return "2022/03/18";
        }
        byte[] ascBuffer=new byte[buffer.length-6];
        System.arraycopy(buffer,5,ascBuffer,0,ascBuffer.length);

        String s=new String(ascBuffer);
        String ss=s.substring(6,16);
        return ss;
    }
}
